import hRequest from "@service/index";
import type { Tpage_course } from "@/models/page_course";
import type { Trestem } from "@/models/restem";
import type { Tcourse } from "@/models/course";
import type { Tsourcefile } from "@/models/sourcefile";
import type { Tpage } from "@/models/page";

export async function course_page(params) {
    const res = await hRequest.get<Tpage_course>({url:"/course/page",params});
    return res;
}

export async function course_collect(params) {
    const res = await hRequest.post<Tpage_course>({url:"/course/collect",params});
    return res;
}

export async function course_getone(params) {
    const res = await hRequest.get<Trestem & {data:Tcourse}>({url:"/course/getOne",params});
    return res;
}

export async function get_mycourse(params) {
    const res = await hRequest.get<Tpage_course>({url:"/user/getMyCollect",params});
    return res;
}

export async function remove_Collect(params) {
    const res = await hRequest.delete<Tpage_course>({url:"/course/removeCollect",params});
    return res;
}

export async function get_sourcefile(params) {
    const res = await hRequest.get<Trestem & { data: Tpage &{ records: Tsourcefile[]} }>({url:"/multipart/getOneCourseFile",params});
    return res;
}

export async function get_file(params) {
    const res = await hRequest.get<Trestem & {data:string}>({url:"/multipart/getFliePath",params});
    return res;
}

export async function uploadFileInfo(data) {
    const res = await hRequest.post<Trestem & { data:any }>({url:"/multipart/uploadFileInfo",data},"application/json");
    return res;
}

export async function course_code(data) {
    const res = await hRequest.put<Trestem & { data:any }>({url:"/code/update",data});
    return res;
}   